<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<title>
		Javascript Audio Processing
	</title>
	<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js?autoload=true&amp;skin=sunburst&amp;lang=css" defer="defer"></script>
	<!-- show all line numbers-->
	<style type="text/css">
		body, button {
			font-family:Arial, Helvetica, sans-serif;
			font-size: 16px;
		}
		.prettyprint ol.linenums>li {
			list-style-type: decimal
		}
	</style>
	<script src="../build/maximilian.js"></script>
</head>

<body>
	<div style="display: inline-block;">
		<h1> Test Tone </h1>
		<p> A simple 440Hz sinewave. </p>
		<div>
			<pre class="prettyprint lang-js linenums:true" id="quine" style="border:1px solid #88c; width: 750px; float: left;">

let m = maximilian();

/**	
 * maxiAudio.init() initialises the Audio Context and should execute in a button click event handler to prevent the console warning 
 * "The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. https://goo.gl/7K7WLu"
 */
let playAudio = () => {

  let myOsc = new m.maxiOsc();
  let maxiAudio = new m.maxiAudio();

  maxiAudio.init();

  maxiAudio.play = function () {
    return myOsc.sinewave(440);
  }
}

const playButton = document.getElementById('playButton');
playButton.addEventListener("click", () => playAudio());

		  </pre>
	  </div>
	  <button id="playButton">Play</button>
  </div>
	</body>

<!-- Our javascript code -->
<script type="text/javascript">

	let m = maximilian();

/**	
 * maxiAudio.init() initialises the Audio Context and should execute in a button click event handler to prevent the console warning 
 * "The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. https://goo.gl/7K7WLu"
 */
	let playAudio = () => {

		let myOsc = new m.maxiOsc();
		let maxiAudio = new m.maxiAudio();

		maxiAudio.init();

		maxiAudio.play = function () {
			return myOsc.sinewave(440);
		}
	}

	const playButton = document.getElementById('playButton');
	playButton.addEventListener("click", () => playAudio());

</script>
</html>